package smartbus;

import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;

import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.DatePicker;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.myapplication.R;

import java.text.SimpleDateFormat;
import java.util.Date;

public class RevealtimeActivity extends AppCompatActivity {

    private ImageView but_lawyerList;
    private ImageView left;
    private ImageView right;
    private DatePicker time;
    private TextView content;

    @RequiresApi(api = Build.VERSION_CODES.O)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_revealtime);
        iinitview();
        //返回
        but_bloak();
        //获取时间
        gettime();
        //第三步页面

    }

    @RequiresApi(api = Build.VERSION_CODES.O)
    private void gettime() {
        time.setOnDateChangedListener(new DatePicker.OnDateChangedListener() {
            @Override
            public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                Date date = new Date();
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm:ss");
                String time = simpleDateFormat.format(date);
                String Data = year + "年-" +monthOfYear + "月-" + dayOfMonth + "日 " + time;
                content.setText(Data);
            }
        });
    }

    private void but_bloak() {
        but_lawyerList.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                RevealtimeActivity.this.finish();
            }
        });

        left.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                RevealtimeActivity.this.finish();
            }
        });
    }

    private void iinitview() {
        but_lawyerList = findViewById(R.id.but_lawyerList);
        left = findViewById(R.id.left);
        right = findViewById(R.id.right);
        time = findViewById(R.id.time);
        content = findViewById(R.id.content);
    }
}